$(document).ready(function(){
	if (document.getElementById('login_form'))
		{
		$("#login_form").ajaxForm({
			dataType:"json",
			url:'/member/login?refer=/',
			beforeSubmit:function(){
			if($.trim($("input[name='username']").val()) == '')
			{
				alert("请填写用户名");
				$("input[name='username']").focus();
				return false;
			}
			else if($.trim($("input[name='password']").val()) == '')
			{
				alert("请填写密码");
				$("input[name='password']").focus();
				return false;
			}
		},
				success:function (data){
					if(data.statusCode == 200)
					{
						window.location.href=data.forwardUrl;
					}
					else if(data.statusCode = 300)
					{
						alert(data.message);
						window.location.href='/member/login.html';
					}
					else
					{
						alert("操作出错");
					}
				}
			});		
		}
});

function SetHome(obj,vrl) {
	try
	{
		obj.style.behavior='url(#default#homepage)';
		obj.setHomePage(vrl);
		return;
	}
	catch(e){
		if(window.netscape) {
			try {
				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
			}
			catch (e) {
				alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将[signed.applets.codebase_principal_support]设置为'true'");
			}
			var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
			prefs.setCharPref('browser.startup.homepage',vrl);
		}
	}
}

// 添加到收藏夹
function add_bookmark(A,B){
	if(window.sidebar){
		window.sidebar.addPanel(A,B,"");
	}
	else if(document.all){
		window.external.AddFavorite(B,A);
	}
	else if(window.opera&&window.print)
	{
		return true;
	}
}

//uhaozi@qq.com,2011.01.14
$(function(){
	var a1 = document.URL;
	var a2 = $(".sitenav a");
	for (var i = 0; i < a2.length; i++) {
		if (a1==$(a2[i]).attr("href")) {
			$(a2[i]).addClass("cur").siblings().removeClass("cur");
		}
	}
	//moregame
	$('.moregame').hover(function(){
		$('.topgames').show().hover(function(){},function(){
			$(this).hide();
		})
	})
	//mygames
	$('.mygames').hover(function(){
		$('.mygameslist').show().hover(function(){},function(){
			$(this).hide();
		})
	})
	//news
	$('.news h3 a').each(function(i){
		$(this).hover(function(){
			$(this).addClass('cur').siblings('a').removeClass('cur');
			$($('.news div')[i]).show().siblings('div').hide();
		})
	})
})

function changTab(a,id,cid){
	//console.log($(a).parents("dd").children("h2").children("span").children("a") );
	$(a).parents("dd").children("h2").children("span").children("a").removeClass();
	//$(".cur").removeClass();
	$(a).addClass("cur");
	$("#"+cid).removeAttr("style");
	$("#"+id).css("display","block");
}